//
//  StudyDetailModel.swift
//  BLH
//
//  Created by zhangshumeng on 2021/8/12.
//

import UIKit

struct StudyDetailModel: Codable {
    let id: String
    let title: String
    let title2: String
    let image: String
    let image2: String
    let image16x9: String
    let image23x8: String
    let video: String
    let pid: String
    let cateId: String
    let cateType: String
    let hot: String
    let count: String
    let totalCount: String
    let mediaType: String
    let publish: String
    let tags: String
    let tags2: String
    let detailImages: String
    let knowImages: String
    let hasJiaoju: String
    let parentZl: String
    let memberFree: String
    let progressNs: String
    let userProgressSum: String
    let icon: String
    let items: String
    let interactLesson: LessonModel
    let aicLesson: String
    let price: String
    let memberPrice: String
    let saleTitle: String
    let studyCount: String
            
}

struct LessonModel: Codable {
    let id: String
    let resourceName: String
    let resourceId: String
    let publish: String
    let zhuanlanId: String
    let resourceUrl: String
    
    var imageBaseName: String {
        switch resourceName {
        case "SX":
            return "bg_shuxue_"
        case "YY":
            return "bg_yingyu_"
        case "PY":
            return "bg_pinyin_"
        default:
            return "bg_shizi_"
        }
    }
}

////////////
struct StudySecModel: Codable {
    let cateId: String
    let name: String
    let originalCateId: String
    let description: String
    let tags: String
    let video: String
    let detailImages: String
    let cover: String
    let items: [StudySecItemModel]
}

struct StudySecItemModel: Codable {
    let secId: String
    let name: String
    
    let unitId: String
    let coverHor: String
    let idxName: String
    let coverVer: String
    let description: String
    let learnedCount: String
    let itemCount: String
    let status: String
    let free: String
    
    var index: Int {
        return Int(unitId) ?? 0
    }
    
    var nameIndex: Int {
        return Int(secId) ?? 0
    }
}

////////////
struct StudyUnitModel: Codable {
    let cateId: String
    let secId: String
    let originalCateId: String
    let originalSecId: String
    let name: String
    let items: [StudySecItemModel]
}
